/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * Derived Key Set Collection Class
 *      Provides a custom collection class for storing DerivedKeySet instances.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;

namespace Adaptive.Foundation.Security
{
    /// <summary>
    /// Provides a custom collection class for storing <see cref="DerivedKeySet"/> instances.
    /// </summary>
    public class DerivedKeySetCollection : GenericCollectionBase<DerivedKeySet>
    {
        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
         *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        public DerivedKeySetCollection()
            : base()
        {
        }
        #endregion

        /*--------------------------------------------------------------------------------
         * Protected Methods / Event Methods
         *------------------------------------------------------------------------------*/
        #region Protected Methods / Event Methods
        /// <summary>
        /// Gets the reference key value used to identify the supplied object instance
        /// once stored in the collection.
        /// </summary>
        /// <param name="itemToGetKeyFor">
        /// The <see cref="DerivedKeySet"/> instance being stored in the collection.
        /// </param>
        /// <returns>
        /// The reference key value used to reference the instance.
        /// </returns>
        protected override string GetKeyForObject(DerivedKeySet itemToGetKeyFor)
        {
            if (itemToGetKeyFor.Index == 0)
                return Count.ToString();
            else
                return itemToGetKeyFor.Index.ToString();
        }
        #endregion
    }
}